package com.ddlc.hprogress

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        cb_with_anim_or_not.setOnCheckedChangeListener { v, isChecked ->
            hpv_progress.setWithAnim(isChecked)
        }
        cb_with_click_or_not.setOnCheckedChangeListener { v, isChecked ->
            hpv_progress.setWithClick(isChecked)
        }

        btn_set_progress_with_anim.setOnClickListener { v ->
            var progress = 0f
            try {
                progress = et_progress.text.toString().trim().toFloat()
            } catch (e: Exception) {
            }
            hpv_progress.setProgress(progress, true)
        }

        btn_set_progress_without_anim.setOnClickListener { v ->
            var progress = 0f
            try {
                progress = et_progress.text.toString().trim().toFloat()
            } catch (e: Exception) {
            }
            hpv_progress.setProgress(progress, false)
        }
    }
}
